<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>
<script>
    Symbol.each = Symbol("each");

    Array.prototype[Symbol.each] = function (handlerFn) {
        // this -> 调用此方法的实例化对象
        Array.prototype.reduce.call(this, function (prev, item, index, array) {
            handlerFn(item, index, array)
        }, 0)
    }

    var arr = [1, 2, 3, 4];
    arr[Symbol.each](function (item, index, array) {
        console.log(item, index, array);
    })

</script>

</html>